﻿<UserControl x:Class="UserControlLib.MachineInfoControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:cc="clr-namespace:UserControlLib"
             xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
             xmlns:converter="clr-namespace:Infrastructure.Converters;assembly=Infrastructure">
    <UserControl.Resources>
        <DataTemplate x:Key="ImageListBoxTemplate">
            <StackPanel Orientation="Horizontal">
                <CheckBox IsChecked="{Binding IsChecked,Mode=TwoWay}"></CheckBox>
                <TextBlock Text="{Binding ImagePath}" Margin="5 0 0 0"></TextBlock>
            </StackPanel>
        </DataTemplate>
        <converter:UriToCachedImageConverter x:Key="uriToImageConv"></converter:UriToCachedImageConverter>
        <converter:WCNOLinesConverter x:Key="sourceConverter"/>
        <converter:WCNOConverter x:Key="itemConverter"/>
    </UserControl.Resources>
    <telerik:RadBusyIndicator IsBusy="{Binding IsBusy}" BusyContent="{Binding MessageContent}" DisplayAfter="0" IsIndeterminate="True" >
        <!--<Grid Margin="5">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            <Border Margin="0 0 0 5" BorderBrush="Gray" BorderThickness="1" CornerRadius="5" Padding="5 0 0 5">
                <StackPanel Grid.Row="0" Orientation="Horizontal" Margin="0 8 0 0" VerticalAlignment="Center">
                    <TextBlock Text="流水线名:" Margin="0 0 5 0"></TextBlock>
                    <telerik:RadComboBox ItemsSource="{Binding WCNOLines,Converter={StaticResource sourceConverter}}" 
                                     SelectedItem="{Binding WCNOSimilar,Converter={StaticResource itemConverter}}" 
                                     IsEditable="False" Width="80" Margin="0 0 5 0"></telerik:RadComboBox>
                    <TextBlock Text="工位名称:" Margin="0 0 5 0"></TextBlock>
                    <telerik:RadComboBox ItemsSource="{Binding StationNamesSimilar}" SelectedItem="{Binding StationNameSimilar}" 
                                     IsEditable="False" Width="80" Margin="0 0 5 0"></telerik:RadComboBox>
                    <TextBlock Text="机种名:" Margin="0 0 5 0"></TextBlock>
                    <TextBox Width="80" Text="{Binding ModelSimilar, UpdateSourceTrigger=PropertyChanged}" Margin="0 0 5 0"></TextBox>
                    
                </StackPanel>
            </Border>-->
        <Grid Margin="5">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="300"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            <Border Grid.Column="0" BorderBrush="Gray" BorderThickness="0 0 1 0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>
                    <StackPanel Grid.Row="0" Orientation="Horizontal" Margin="0 8 0 0">
                        <TextBlock Text="流水线名:" Width="80"></TextBlock>
                        <telerik:RadComboBox ItemsSource="{Binding WCNOLines,Converter={StaticResource sourceConverter}}" 
                                     SelectedItem="{Binding WCNO,Converter={StaticResource itemConverter}}" 
                                     IsEditable="False" Width="180" IsEnabled="{Binding IsEnabled,Mode=OneWay}"></telerik:RadComboBox>
                    </StackPanel>
                    <StackPanel Grid.Row="1" Orientation="Horizontal" Margin="0 8 0 0">
                        <TextBlock Text="工位名称:" Width="80"></TextBlock>
                        <telerik:RadComboBox ItemsSource="{Binding StationNames}" SelectedItem="{Binding SelectedStationName}" 
                                     IsEditable="False" Width="180" IsEnabled="{Binding IsEnabled,Mode=OneWay}"></telerik:RadComboBox>
                    </StackPanel>
                    <StackPanel Grid.Row="2" Orientation="Horizontal" Margin="0 8 0 0">
                        <TextBlock Text="机种名:" Width="80"></TextBlock>
                        <TextBox Width="180"  
                                 IsEnabled="{Binding IsEnabled,Mode=OneWay}">
                            <TextBox.Text>
                                <Binding Path="Model" NotifyOnValidationError="True" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged">
                                    <Binding.ValidationRules>
                                        <DataErrorValidationRule/>
                                    </Binding.ValidationRules>
                                </Binding>
                            </TextBox.Text>
                        </TextBox>
                    </StackPanel>
                    <StackPanel Grid.Row="3" Orientation="Horizontal" Margin="0 8 0 0">
                        <TextBlock Text="背番号:" Width="80"></TextBlock>
                        <TextBox Width="180">
                            <TextBox.Text>
                                <Binding Path="Sebango" NotifyOnValidationError="True" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged">
                                    <Binding.ValidationRules>
                                        <DataErrorValidationRule/>
                                    </Binding.ValidationRules>
                                </Binding>
                            </TextBox.Text>
                        </TextBox>
                    </StackPanel>
                    <StackPanel Grid.Row="4" Orientation="Horizontal" Margin="0 8 0 0">
                        <TextBlock Text="循环播放时间:" Width="80"></TextBlock>
                        <telerik:RadWatermarkTextBox WatermarkContent="单位是秒" Text="{Binding CycleTime,UpdateSourceTrigger=PropertyChanged}" Width="180">
                        </telerik:RadWatermarkTextBox>
                    </StackPanel>
                    <StackPanel Grid.Row="5" Orientation="Vertical" Margin="0 8 0 0">
                        <TextBlock Text="选择图片:" Width="80" HorizontalAlignment="Left"></TextBlock>
                        <telerik:RadListBox SelectedItem="{Binding SelectedImageModel, Mode=TwoWay}" Height="150" HorizontalAlignment="Left"
							ItemsSource="{Binding ImageList}" ItemTemplate="{StaticResource ImageListBoxTemplate}" Width="260" Margin="0 5 0 0"/>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal" Grid.Row="6" HorizontalAlignment="Left" VerticalAlignment="Stretch" Margin="0 8 0 0">
                        <telerik:RadButton Width="80" Height="22" Content="确定" Margin="0 0 5 0" Command="{Binding SaveCommand,Mode=TwoWay}"></telerik:RadButton>
                        <!--<telerik:RadSlider x:Name="sliderScale" Width="170" Margin="10 0" HorizontalAlignment="Left" HandlesVisibility="Visible" Value="1"
                                           Minimum="1" Maximum="5" VerticalAlignment="Center"/>-->
                        <telerik:RadButton Width="80" Height="22" Content="查找相似" Margin="0 0 5 0" Command="{Binding SimilarCommand,Mode=TwoWay}"></telerik:RadButton>
                    </StackPanel>
                </Grid>
            </Border>
            <!--<ScrollViewer Grid.Column="1" Grid.Row="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" HorizontalScrollBarVisibility="Auto"
                              VerticalScrollBarVisibility="Auto">-->
            <Image Grid.Column="1" Grid.Row="0" Source="{Binding SelectedImage,Converter={StaticResource uriToImageConv}}" 
                       SnapsToDevicePixels="True" Stretch="Uniform" RenderTransformOrigin="0.5,0.5">
                <!--<Image.LayoutTransform>
                            <ScaleTransform
									ScaleX="{Binding Value, ElementName=sliderScale, Mode=TwoWay}"
									ScaleY="{Binding Value, ElementName=sliderScale, Mode=TwoWay}" />
                        </Image.LayoutTransform>-->
            </Image>
            <!--</ScrollViewer>-->
        </Grid>
        <!--</Grid>-->

    </telerik:RadBusyIndicator>
</UserControl>
